using System.Collections.Generic;
using System.Linq;
using UnitTestDemo.Models;

namespace UnitTestDemo.Tests
{
    public class FakeRepository:IRepository
    {
        private List<User> _users;

        public FakeRepository()
        {
            _users = new List<User>();
            DidSubmitChanges = false;
        }
        public void Add(User user)
        {
            _users.Add(user);
        }

        public bool DidSubmitChanges { get; set; }
        public User FetchByLoginName(string loginName)
        {
            return _users.First(u => u.LoginName == loginName);
        }

        public void SubmitChanges()
        {
            DidSubmitChanges = true;
        }
    }
}